import request from '@/utils/request'

// 用户相关接口

// 内容相关接口
export const contentApi = {
    // 获取推荐内容
    getRecommendPosts(params) {
        return request({
            url: '/post/recommend',
            method: 'get',
            params
        })
    },

    // 获取关注用户的内容
    getFollowingPosts(params) {
        return request({
            url: '/post/following',
            method: 'get',
            params
        })
    },

    // 获取内容详情
    getPostDetail(postId) {
        return request({
            url: `/post/detail/${postId}`,
            method: 'get'
        })
    },

    // 发布内容
    createPost(data) {
        return request({
            url: '/post/create',
            method: 'post',
            data
        })
    },

    // 点赞内容
    likePost(postId) {
        return request({
            url: '/post/like',
            method: 'post',
            data: { postId }
        })
    },

    // 取消点赞
    unlikePost(postId) {
        return request({
            url: '/post/unlike',
            method: 'post',
            data: { postId }
        })
    },

    // 收藏内容
    collectPost(postId) {
        return request({
            url: '/post/collect',
            method: 'post',
            data: { postId }
        })
    },

    // 取消收藏
    uncollectPost(postId) {
        return request({
            url: '/post/uncollect',
            method: 'post',
            data: { postId }
        })
    }
}

// 评论相关接口
export const commentApi = {
    // 获取评论列表
    getComments(postId, params) {
        return request({
            url: `/comment/list/${postId}`,
            method: 'get',
            params
        })
    },

    // 发表评论
    createComment(data) {
        return request({
            url: '/comment/create',
            method: 'post',
            data
        })
    },

    // 回复评论
    replyComment(data) {
        return request({
            url: '/comment/reply',
            method: 'post',
            data
        })
    },

    // 点赞评论
    likeComment(commentId) {
        return request({
            url: '/comment/like',
            method: 'post',
            data: { commentId }
        })
    }
}

// 搜索相关接口
export const searchApi = {
    // 搜索内容
    searchPosts(params) {
        return request({
            url: '/search/posts',
            method: 'get',
            params
        })
    },

    // 搜索用户
    searchUsers(params) {
        return request({
            url: '/search/users',
            method: 'get',
            params
        })
    },

    // 获取热门搜索
    getHotSearch() {
        return request({
            url: '/search/hot',
            method: 'get'
        })
    }
}

// 消息通知相关接口
export const notificationApi = {
    // 获取消息列表
    getNotifications(params) {
        return request({
            url: '/notification/list',
            method: 'get',
            params
        })
    },

    // 标记消息为已读
    readNotification(notificationId) {
        return request({
            url: '/notification/read',
            method: 'post',
            data: { notificationId }
        })
    },

    // 标记所有消息为已读
    readAllNotifications() {
        return request({
            url: '/notification/readAll',
            method: 'post'
        })
    },

    // 关注用户
    followUser(userId) {
        return request({
            url: '/user/follow',
            method: 'post',
            data: { userId }
        })
    },

    // 取消关注用户
    unfollowUser(userId) {
        return request({
            url: '/user/unfollow',
            method: 'post',
            data: { userId }
        })
    }
} 